<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="content">
                <h:form id="form">  

                    <p:dataGrid var="rest" value="#{restBean2.findAllRest()}" columns="3"  
                                rows="12" paginator="true"  
                                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                rowsPerPageTemplate="9,12,15">  

                        <p:column>  
                            <p:panel header="#{rest.name}" style="text-align:center">  
                                <h:panelGrid columns="1" style="width:100%">  
                                    <p:graphicImage styleClass="dataImg" value="/resources/img/restaurants/#{rest.pic}"/>   

                                    <h:outputText value="#{rest.name}" />  

                                    <p:commandLink update=":form:restDetail" oncomplete="restDialog.show()" title="View Detail">  
                                        <p:graphicImage value="/resources/img/search.png"/>   
                                        <f:setPropertyActionListener value="#{rest}"   
                                                                     target="#{restBean2.restaurant}" />  
                                    </p:commandLink>  
                                </h:panelGrid>  
                            </p:panel>  
                        </p:column>  

                    </p:dataGrid>  

                    <p:dialog header="Restaurant Detail" widgetVar="restDialog" modal="true">  
                        <p:outputPanel id="restDetail" style="text-align:center;" layout="block">  

                            <p:graphicImage styleClass="detailImg" value="/resources/img/restaurants/#{restBean2.restaurant.pic}"/>   

                            <h:panelGrid  columns="2" cellpadding="5">  
                                <h:outputLabel for="name" value="Name : " />  
                                <h:outputText id="name" value="#{restBean2.restaurant.name}" />  

                                <h:outputLabel for="location" value="Location : " />  
                                <h:outputText id="location" value="#{restBean2.restaurant.location}" />
                                <h:outputLink value="viewrestaurant.xhtml">Restaurant's Spots
                                    <f:param name="restId" value="#{restBean2.restaurant.rid.toString()}"/>
                                </h:outputLink>
                            </h:panelGrid>  
                        </p:outputPanel>  
                    </p:dialog>  

                </h:form>  

            </ui:define>

        </ui:composition>

    </body>
</html>
